package yc.star.system.controller;

import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import yc.star.common.controller.BaseController;
import yc.star.common.domain.AppResult;
import yc.star.common.domain.TableDataInfo;
import yc.star.system.domain.user.dto.UserDTO;
import yc.star.system.domain.user.dto.UserQueryDTO;
import yc.star.system.domain.user.vo.UserVO;
import yc.star.system.service.IUserService;

import java.util.List;

@RequestMapping("/user")
@Tag(name = "用户接口")
@RestController
public class UserController extends BaseController {

    @Autowired
    private IUserService userService;

    @GetMapping("/list")
    public TableDataInfo list (UserQueryDTO userQueryDTO) {
        List<UserVO> userVOList = userService.list(userQueryDTO);
        return getTableDataInfo(userVOList);
    }

    @PutMapping("/updateStatus")
    public AppResult<Void> updateStatus (@RequestBody UserDTO userDTO) {
        int rows = userService.updateStatus(userDTO);
        return toAppResult(rows);
    }

}